<template>
    <div class="login-wrap">
        <el-card class="ms-login" shadow="always">
            <div class="ms-title">
                二手交易平台
            </div>
            <el-form :model="param" :rules="rules" ref="login" label-width="100px" class="ms-content" label-position="top">
                <label for="" class="form-label">用户名/手机号</label>
                <el-form-item prop="username" >
                    <el-input v-model="param.username" placeholder="用户名/手机号">
                    </el-input>
                </el-form-item>
                <label for="" class="form-label">密码</label>
                <el-form-item prop="password" >
                    <el-input
                        type="password"
                        placeholder="请输入密码"
                        show-password
                        v-model="param.password"
                        @keyup.enter.native="submitForm()"
                    >
                    </el-input>
                </el-form-item>
                <div @click="toSignIn">
                    没有账号？/现在注册
                </div>
                <div class="login-btn">
                    <el-button type="primary" @click="submitForm()">登录</el-button>
                </div>
            </el-form>
        </el-card>
    </div>
</template>

<script>
export default {
    data: function() {
        return {
            param: {
                username: '',
                password: '',
            },
            rules: {
                username: [{ required: false, message: '请输入用户名', trigger: 'blur' }],
                password: [{ required: false, message: '请输入密码', trigger: 'blur' }],
            },
        };
    },
    methods: {
        submitForm() {
            this.$refs.login.validate(valid => {
                if (valid) {
                    // 暂时静态
                    if (this.param.username == 'admin'){
                        this.$router.push('/system/goods');
                        localStorage.setItem('ms_username',this.param.username)
                    }
                    this.$router.push('/');
                    localStorage.setItem('ms_username',this.param.username)
                } else {
                    this.$message.error('请输入账号和密码');
                    return false;
                }
            });
        },
        // 跳转注册
        toSignIn(){
            this.$router.push('/signIn');
        }
    },
};
</script>

<style scoped>
.login-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    /* background-image: url(../../assets/img/login-bg.jpg); */
    background-color: #fff;
    background-size: 100%;
}
.ms-title {
    margin-top: 70px;
    width: 100%;
    line-height: 50px;
    text-align: center;
    font-size: 20px;
    color: #000;
    /* border-bottom: 1px solid #ddd; */
}
.ms-login {
    position: absolute;
    left: 50%;
    top: 50%;
    height: 450px;
    width: 350px;
    margin-left: -175px;
    margin-top: -225px;
    border-radius: 5px;
    background: #fff;
    overflow: hidden;
}
.ms-content {
    padding: 30px 30px;
}
.login-btn {
    text-align: center;
}
.login-btn button {
    width: 100%;
    height: 36px;
    margin-bottom: 10px;
}
.login-tips {
    font-size: 12px;
    line-height: 30px;
    color: #fff;
}
.form-label{
    font-size: 14px;
}
</style>